package com.autocareai.lib.extension

import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/5/7
 *     desc   : Fragment扩展
 *     version: 1.0.0
 * </pre>
 */

/**
 * Fragment 是否被销毁
 */
fun Fragment.isFragmentDestroyed(): Boolean {
    return lifecycle.currentState == Lifecycle.State.DESTROYED
}

fun Fragment.gone(vararg arr: View) {
    arr.forEach {
        if (it.visibility != View.GONE) {
            it.visibility = View.GONE
        }
    }
}

fun Fragment.visible(vararg arr: View) {
    arr.forEach {
        if (it.visibility != View.VISIBLE) {
            it.visibility = View.VISIBLE
        }
    }
}

fun Fragment.invisible(vararg arr: View) {
    arr.forEach {
        if (it.visibility != View.INVISIBLE) {
            it.visibility = View.INVISIBLE
        }
    }
}